/**
 * Created by David on 2019/1/4.
 */
/*function singleNumber(nums) {
    const obj={};
    for(let i=0;i<nums.length;i++){
        obj[nums[i]]=obj[nums[i]]?obj[nums[i]]+1:1;
    }
    for(let key in obj){
        if(obj[key]===1){
            return Number(key);
        }
    }
}*/
function singleNumber(nums) {
    for (let i = 1; i < nums.length; i++) {
        nums[0] ^= nums[i];
    }
    return nums[0];
};
console.log(singleNumber([2, 2, 1, 4, 4, 5, 5, 1,8,8,8])); // 8